package com.chinasofti.framework.dataaccess;

import java.lang.reflect.Type;
import java.util.HashMap;

import com.chinasofti.framework.data.Entity;
import com.chinasofti.framework.data.FieldType;
/**
 * @author yaoyang
 *
 * @date 2011-11-23
 */

public class Parameter extends Entity  {
	
	
	private static HashMap<String, FieldType> m_fields;
	private static final String ENTITY_NAME = "Parameter";
	private static final String KEY_FIELD = "name";
	
	public static final String FIELD_NAME = "name";
	public static final String FIELD_TYPE = "type";
	public static final String FIELD_VALUE = "value";
	
	
	@Override
	protected void init() {
		if(m_fields == null) {
			m_fields = new HashMap<String, FieldType>();
			m_fields.put(FIELD_NAME, new FieldType(String.class));
			m_fields.put(FIELD_TYPE, new FieldType(Type.class));
			m_fields.put(FIELD_VALUE, new FieldType(String.class));
		}
	}
	
	@Override
	public ParameterParser getParser() {
		return new ParameterParser();
	}

	@Override
	public HashMap<String, FieldType> getFieldTypes() {
		return m_fields;
	}

	@Override
	public String getKeyField() {
		return KEY_FIELD;
	}

	@Override
	public String getEntityName() {
		return ENTITY_NAME;
	}
	
	//自定义代�?
	public Parameter(String name, Type type, String value) {
		set(FIELD_NAME, name);
		set(FIELD_TYPE, type);
		set(FIELD_VALUE, value);
	}
	
	public Parameter(String name, String value) {
		this(name, String.class, value);
	}
	
	public Parameter() {
	}
	
	public String getName() {
		return getString(Parameter.FIELD_NAME);
	}
	
	public Type getType() {
		return (Type)get(Parameter.FIELD_TYPE);
	}
	
	public String getValue() {
		return getString(Parameter.FIELD_VALUE);
	}
	
}
